/*
 * Copyright (c) 2013-2018 上海汇数数据. All rights reserved.
 * @(#) RegionConstants.java 2018-08-19 18:34
 */

package cn.jh.common.core.cn;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


/**
 * @author Fuchun
 * @since 1.0
 */
class RegionConstants {

    static final String STATES_RES_PATH = "/META-INF/data/states.json";
    static final String CITIES_RES_PATH = "/META-INF/data/cities.json";
    static final String COUNTIES_RES_PATH = "/META-INF/data/counties.json";
    static final String REGIONS_RES_PATH = "/META-INF/data/regions.dat";
    static final String STATE_CODE_SUFFIX = "0000";
    static final String CITY_CODE_SUFFIX = "00";

    static final int STATE_COUNT = 34;
    static final int CITY_COUNT = 351;
    static final int COUNTY_COUNT = 3039;

    static final Comparator<Region> CODE_COMPARATOR = Comparator.comparing(Region::getCode);

    static List<Region> listRegions(Collection<Region> regions) {
        List<Region> list = new ArrayList<>(regions);
        list.sort(CODE_COMPARATOR);
        return Collections.unmodifiableList(list);
    }
}
